# -*- coding=utf-8 -*-
'''
  对象的序列化及反序列化
'''
import pickle
import pprint


class Student(object):
    def __init__(self, name, age):
        self.name = name
        self.age = age

    def __str__(self):
        return 'name: '+self.name+' age: '+self.age


def main():
    stu1 = Student('张涵弈', 23)
    file = open('src/log.pkl','wb')
    pickle.dump(stu1,file)

    # file = open('log.pkl','rb')
    # data1 = pickle.load(file)
    # pprint.pprint(data1.age)

    file.close()

if __name__ == '__main__':
    main()
